package com.tang.util;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * redis连接
 *
 * @author fulin.tang
 * @version V3.0
 * @since 2021/9/13 17:45
 */
public class RedisUtils {

    private final AtomicInteger stock = new AtomicInteger(0);

    public RedisUtils() {
        ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1);
        scheduledExecutorService.scheduleAtFixedRate(() -> stock.addAndGet(1), 0, 100000, TimeUnit.MICROSECONDS);
    }

    public int getStockUsed() {
        return stock.get();
    }
}
